import base64




import os.path
import sys
import time
import datetime
import uvicorn
from dateutil.utils import today

from libs.svr.router import app
from libs.svr.settings import settings


from libs.comps.common.component import manager , TComponent
from libs.utils.time_utils import TUtilsTime
import libs.comps.common.compDB
import libs.comps.common.compKV
import libs.comps.common.compTDB

import libs.comps.model.iot.iot_api
import libs.comps.model.iot.iotSchedule
import libs.comps.model.iot.iot_mqttdtu_645

#import libs.comps.model.iot.iot_dtu_mq_645
#import libs.comps.model.iot.iot_dtu645
#import libs.comps.model.iot.iot_calculator




if __name__=="__main__":
    print('')
    current_file_abs_path = os.path.dirname(os.path.abspath(__file__))
    fn = f"{current_file_abs_path}/defaultSettings.json"
    if len(sys.argv)>=2:
        sc = sys.argv[2]
        fn = f"{current_file_abs_path}/{sc}.json"
    settings.settingsFn = fn
    manager.rootPath = os.path.dirname(__file__)
    manager.loadComps()
    uvicorn.run(
        "apisvr:app" ,
        host= settings.info["server"]['host'],
        port= settings.info["server"]['port']
    )